#-*- coding.utf-8 -*-
import os
from moviepy.editor import VideoFileClip as vfc,AudioFileClip as afc
PATH_ROOT = 'C:/FFOutput/'

if __name__ == '__main__':
    #----------------音频处理 begin----------------#
    for li in os.listdir(PATH_ROOT):
        #print(li)
        #break
        _arc = os.path.join(PATH_ROOT,li)
        if os.path.isfile(_arc):
            print(_arc)
            clip = afc(_arc)
            clip_source_duration = clip.duration
            #print(clip_source_duration)
            #exit()
            target_clip = clip.subclip('0:02:30','1:54:17')
            target_clip.write_audiofile(_arc.replace('.mp3','clip.mp3'))
            print(_arc,'processed.')
    exit()
    #----------------音频处理 end----------------#
    #----------------视频处理 begin----------------#
    for li in os.listdir(PATH_ROOT):
        #print(li)
        _arc = os.path.join(PATH_ROOT,li)
        if os.path.isfile(_arc):
            print(_arc)
            clip = vfc(_arc)
            clip_source_duration = clip.duration
            #print(clip_source_duration)
            target_clip = clip.subclip(160,clip_source_duration-221)
            target_clip.write_audiofile(_arc.replace('替换',''))
            print(_arc,'processed.')
    #----------------视频处理 begin----------------#